package com.bianmaba.netty.client;

import com.bianmaba.netty.client.core.BootNettyClient;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@Log4j2
@EnableAsync
public class ClientMainApplication implements CommandLineRunner {
    @Autowired
    private BootNettyClient client;

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(ClientMainApplication.class);
        app.run(args);

        log.info("springboot启动");
    }

    @Async
    @Override
    public void run(String... args) throws Exception {
        /**
         * 使用异步注解方式启动netty客户端服务
         */
        int port = 8888;
        client.connect(port, "127.0.0.1");
    }

}
